{extend name="public/list_page"/}
{block name="content"}
<div class="layui-card">
    <div class="layui-card-body">
        <form id="termsFormData" class="layui-form layui-form-pane" autocomplete="off">
            <div class="layui-tab layui-tab-card">
                <ul class="layui-tab-title">
                    <li class="layui-this">基本内容</li>
                    <li>SEO内容</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <div class="layui-form-item">
                            <label class="layui-form-label">标题</label>
                            <div class="layui-input-block">
                                <input type="text" name="title" id="title" value="{$info.title}" placeholder="请输入标题"
                                       class="layui-input">
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">内容</label>
                                <div class="layui-input-block">
                                    <!--富文本-->
                                    <script id="privacyContent" name="content" type="text/plain"></script>
                                </div>
                                <input type="hidden" value="{$info.content}" id="privacyEdit">
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab-item">
                        <div class="layui-form-item">
                            <label class="layui-form-label">SEO标题</label>
                            <div class="layui-input-block">
                                <input type="text" name="seo_title" id="privacySeoTitle" value="{$info.seo_title}" class="layui-input" placeholder="请输入SEO标题，长度控制在60个字符内">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">SEO关键词</label>
                            <div class="layui-input-block">
                                <input type="text" name="seo_keywords" id="privacySeoKeywords" value="{$info.seo_keywords}" class="layui-input" placeholder="请输入SEO关键词，每个关键词用英文逗号隔开">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">SEO描述</label>
                            <div class="layui-input-block">
                                <textarea name="seo_describe" id="privacySeoDescribe" placeholder="请输入SEO描述" class="layui-textarea">{$info.seo_describe}</textarea>
                            </div>
                        </div>
                    </div>
                    <div class="btn-block">
                        <button type="button" onclick="sendTerms()" class="layui-btn layui-btn-normal"><i class="fa fa-check"></i>提交</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}

{block name="js"}
<!--UEdit-->
<!--这两个文件要注意引用顺序-->
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
<!-- 配置文件 -->
<script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.js"></script>

<!--UEdit-->
<script type="text/javascript">
    var privacyContent = UE.getEditor('privacyContent',{initialFrameHeight:500});

    privacyContent.ready(function () {
        privacyContent.setContent($("#privacyEdit").val())
    })
</script>

<script>
    layui.use(['form','element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            element = layui.element;
    })

    function sendTerms() {
        //弹出遮罩层，防止多次点击
        var privacyLoad = layer.load(1,{shade:[0.5,'#FFF'],time:0})

        let data = $("#termsFormData").serialize()

        ajaxRequest("{:url('policy/policy',['id' => 1])}",data,function (res) {
            if (res.code == 'suc') {
                sucMsg(res.msg)
            }else {
                errMsg(res.msg)
            }
        })
        //关闭遮罩层
        layer.close(privacyLoad)
    }
</script>
{/block}